<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background: #ccc;
            position: absolute;
        }
    </style>
    <script type="text/babel">
        class Drag extends React.Component{
            constructor(...args){
                super(...args);

                this.state = {x:0, y:0};
            }

            fn(ev){
                let disX = ev.pageX - this.state.x;
                let disY = ev.pageY - this.state.y;

                let _this = this;
                document.onmousemove = function (ev) {
                    _this.setState({
                        x: ev.pageX - disX,
                        y: ev.pageY - disY
                    });
                };

                document.onmouseup = function () {
                    document.onmousemove = null;
                    document.onmouseup = null;
                };
            }

            render(){
                return <div style={{left: this.state.x+'px',top:this.state.y+'px'}}
                            onMouseDown={this.fn.bind(this)} className="box">
                    1111
                </div>;
            }
        }


        window.onload = function () {
            var  oDiv = document.getElementById('root');

            ReactDOM.render(
                <Drag/>,
                oDiv
            );
        }
    </script>
</head>
<body>
<div id="root"></div>
</body>
</html>